<template>
    <div style="padding:20px 24px; background: #fff;border-radius: 12px;position: relative;" class="body">
        <el-tabs v-model="activeName">
            <el-tab-pane label="理论课程" name="理论">
            </el-tab-pane>
            <el-tab-pane label="实操" name="实操">
            </el-tab-pane>
            <el-tab-pane label="试题讲解" name="试题">
            </el-tab-pane>
        </el-tabs>
        <ul class="packbox" v-loading="loading">
          <van-empty
            description="
              当前课程暂无知识点
            "
            v-if="list.length == 0"
          />
            <li
            v-for="(item) in list"
            :key="item.id"
            @click="rowlistGo(item)"
            :class="activeid == item.id?'activeLi':''"
            >
            <p :title="item.title">
                {{ item.title }}{{item.kind&&item.kind=='选学'?'(选学)':''}}
            </p>
            <div style="display: flex; justify-content: space-between">
                <i style="color: #B0B0B0">{{ item.score }}学时</i>
                <div
                class="ticp"
                style="
                    padding: 2px 3px;
                    background: rgba(208, 2, 27, 0.06);
                    color: #D0021B;
                    border-radius: 4px;
                "
                v-if="item.status == '已学完'"
                >
                已学完
                </div>
                <div
                class="ticp"
                style="
                    padding: 2px 3px;
                    background: #EAF0FF;
                    color: #165EFF;
                    border-radius: 4px;
                "
                v-else
                >
                待学习
                </div>
            </div>
            </li>
        </ul>
        <p
          style="
            font-size: 14px;
            color: #D0021B;
            margin: 0;
            margin-left: 16px;
            padding: 6px 12px;
            background: rgba(208, 2, 27, 0.06);
            border-radius: 8px;
            position: absolute;
            right: 24px;
            top: 18px;
          "
        >
          点击学习下列知识点，查看对应的培训课程，学完所有课程方可增加
          该知识点对应的学时
        </p>
    </div>
</template>

<script>
import { materialkmlist, materialList, collectlist } from "@/api/admin.js";
import { getsubject_id, getsubjectTitle, getapplyid } from "@/utils/auth";
export default {
    props:['default','prtefName'],
  data() {
    return {
      value: "",
      subjct: "",
      serchinput: "",
      list: [],
      dataList: [], //内容表
      fileData: [],
      arrs: "",
      activeid: "",
      activeName:this.prtefName?this.prtefName:'理论',
      loading:false,
      defaultA:this.default,
    };
  },
  methods: {
    //如果知识点为空则清空课程
    rowlistGo(row) {
      this.activeid = row.id;
      this.$emit('clickrow', row);
    //   if (this.formPage) {
    //     this.listData(row.id)
    //   } else {
    //     this.$router.push({
    //       name: "curriculumindex",
    //       params: { ...row, tabLabel: this.tabLabel,activeName:this.activeName },
    //     });
    //   }
    },
    // //课件条件列表
    listData() {
      this.list = [];
      this.loading=true
      materialkmlist({
        msid: getsubject_id(),
        applyid: getapplyid(),
        cate: this.activeName,
      }).then((res) => {
        this.loading=false
        this.list = [];
        if (res.code == 200) {
          this.list = res.data;
          
          if(this.defaultA=='true'){
            if(this.list.length==0){
              this.rowlistGo({id:null})
            }else{
              this.rowlistGo(this.list[0])
            }
          }else if(this.defaultA){
            if(this.list.length==0){
              this.rowlistGo({id:null})
            }else{
              this.rowlistGo(this.list.filter(item=>item.id==this.defaultA)[0])
            }
          }else{
            this.activeid = ''
          }
        }
      });
    },
    // //收藏列表
    // collList() {
    //   this.dataList = [];
    //   this.$emit("loading", true);
    //   collectlist({ msid: this.subjct, subjectid: getsubject_id() }).then(
    //     (res) => {
    //       this.dataList = [];
    //       this.$emit("loading", false);
    //       if (res.code == 200) {
    //         let num = -1;
    //         for (let i = 0; i < res.data.length; i++) {
    //           let item = res.data[i];
    //           if (i % 5 == 0) {
    //             this.dataList.push([]);
    //             num++;
    //           }
    //           this.dataList[num].push(item);
    //         }
    //         this.$emit("fileLists", this.dataList, 0, this.subjct);
    //       }
    //     }
    //   );
    // },
  },
  watch:{
    activeName(){
      if(this.defaultA){
        this.defaultA = 'true'
      }
      this.listData()
    }
  },
  created() {
    // if(this.prtefName){
    //   this.activeName = this.prtefName
    // }else{
    // }
    this.listData()
  },
};
</script>

<style lang="scss">

</style>
<style lang="scss" scoped>
.body{
  ::v-deep{
    .van-empty{
      width: 100%;
    }
    .el-tabs__content{
      position: static;
    }
    .el-tabs__header{
      margin: 0;
    }
    .el-tabs {
      position: relative;
    }
    .el-tabs__item{
      height: 50px;
      color: #69718C !important;
    }
    .is-active{
      color: #333333 !important;
    }
    .el-tabs__active-bar{
      background: #175dff;
      
    }
    .el-tabs__nav-wrap::after{
      height: 1px;
    }
  }
}
.disnode{

  .el-tabs__nav{
    display: flex;
    margin-bottom: 16px;
    border: 1px solid #ddd;
    border-radius: 5px;
    overflow: hidden;
  }
    .el-tabs__active-bar{
      display: none !important;
    }
    .el-tabs__item{
      height: 33px !important;
      line-height: 1.2 !important;
      width: 80px !important;
      display: flex;
      align-items: center;
      justify-content: center;
      background: #F5F5F5;
      font-size: 14px;
      padding:0;
      color: #999999;
    }
    .is-active{
      background: #fff;
      color: #000 !important;
    }
    .el-tabs__item:hover{
      color: #000;
    }
    .el-tabs__nav-wrap::after{
      background: #eee;
      height: 1px;
    }
}
.packbox {
    // margin-top: 24px;
    display: flex;
    flex-wrap: wrap;
    width: calc(100% + 16px);
    margin-left: -8px;
    // min-height: 303px;
    // justify-content: space-between;
    li {
      width: 252px;
      height: 85px;
      padding: 10px 16px;
      border-radius: 12px;
      background: #f7f7f7;
      // margin-left: 16px;
      margin: 0 8px;
      margin-top: 16px;
      font-size: 14px;
      cursor: pointer;
      display: flex;
      justify-content: space-between;
      flex-direction: column;
      &:hover {
        background: #175dff;
        color: #fff;
        i {
          color: #dddddd !important ;
        }
        .ticp {
          background: #fff !important;
          // color: #175dff !important;
        }
      }
    }
    p {
      line-height: 1.2;
      width: 100%;
      -webkit-line-clamp: 2;
      word-break: break-all;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      overflow: hidden;
      padding: 0;
      margin: 0;
    }
    .noMonemargin {
      margin-left: 0;
    }
    .noMonemarginTop {
      margin-top: 0;
    }
    .activeLi {
      background: #175dff;
      color: #fff;
      i {
        color: #dddddd !important ;
      }
      .ticp {
        background: #fff !important;
        // color: #175dff !important;
      }
    }
  }  
</style>